// div 中放置子元素
import { init } from "snabbdom/build/package/init.js";
import { h } from "snabbdom/build/package/h.js";

const patch = init([]);

// 利用h函数创建带有子元素的VNode
let vNode = h("div#container", [h("h1", "Hello Snabbdom"), h("p", "这是一个p标签")]);

let app = document.querySelector("#app");

let oldVNode = patch(app, vNode);

setTimeout(() => {
    vNode = h("div#container", [h("h1", "Hello World"), h("p", "Hello P")]);
    patch(oldVNode, vNode);

    // 清空页面元素
    patch(oldVNode, h('!'))
}, 2000);
